package com.Servlet;

import com.Service.Impl.UserServiceImpl;
import com.Service.UserService;
import com.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @Author: 冷俊杰
 * @Description: 根据ID查询
 * @DateTime: 2022/6/20 15:18
 **/
@WebServlet(name = "/ServletUserById",value = "/ServletUserById")
public class ServletUserById extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService service = new UserServiceImpl();
        Integer id= Integer.parseInt(request.getParameter("id"));
        User user = service.SelectUserById(id);
        System.out.println("结果" + user);
        PrintWriter out = response.getWriter();
        out.print(user);
//        request.getRequestDispatcher("./UserManage.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
